<?php declare(strict_types=1);

/**
 * @author      guosir
 * @copyright   2023-2025 owner
 **/

namespace Srv\Apps\Apis\Task\Ctl;

use Srv\Apps\Proto\DTO\DbJson\TaskConfBindDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfChasingDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfCheckDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfInviteDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfLotteryDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfNoticeDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfPlayDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfRechargeDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfShareAppDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfTheaterDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfWatchAdDTO;
use Srv\Apps\Proto\DTO\DbJson\TaskConfWatchDTO;
use Srv\Apps\Proto\DTO\Task\TaskEditDTO;
use Srv\Apps\Proto\DTO\Task\TaskListDTO;
use Srv\Apps\Proto\Enum\Task\TaskTypeEnum;
use Srv\Apps\Proto\Enum\YesOrNoEnum;
use Srv\Apps\Proto\VO\DbJson\TaskConfBindVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfChasingVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfCheckVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfInviteVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfLotteryVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfNoticeVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfPlayVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfRechargeVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfShareAppVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfTheaterVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfWatchAdVO;
use Srv\Apps\Proto\VO\DbJson\TaskConfWatchVO;
use Srv\Apps\Proto\VO\Task\TaskListVO;
use Srv\Apps\Proto\VO\Task\TaskVO;
use Srv\Libs\Common\CommArray;
use Srv\Libs\Common\CommString;
use Srv\Libs\Common\CommTime;
use Srv\Libs\Frame\ControllerAbstract;
use Srv\Libs\Frame\Page;
use Srv\Libs\Storage\DataMysql;

final class TaskCtl extends ControllerAbstract
{
    private ?DataMysql $DbAuto              = null;     // DB-Write
    private array $taskTypeNameList         = [
        TaskTypeEnum::TASK_TYPE_UNKNOWN     => '未知',
        TaskTypeEnum::TASK_TYPE_NOTICE      => '订阅消息',
        TaskTypeEnum::TASK_TYPE_BIND        => '绑定第三方',
        TaskTypeEnum::TASK_TYPE_WATCH_AD    => '看视频得看点',
        TaskTypeEnum::TASK_TYPE_THEATER     => '剧场看一看',
        TaskTypeEnum::TASK_TYPE_CHASING     => '天天追剧',
        TaskTypeEnum::TASK_TYPE_SHARE_APP   => '分享视频App',
        TaskTypeEnum::TASK_TYPE_PLAY        => '看新剧',
        TaskTypeEnum::TASK_TYPE_RECHARGE    => '充值回馈',
        TaskTypeEnum::TASK_TYPE_CHECK       => '签到',
        TaskTypeEnum::TASK_TYPE_WATCH       => '看视频领奖励',
        TaskTypeEnum::TASK_TYPE_LOTTERY     => '福利转盘',
        TaskTypeEnum::TASK_TYPE_INVITE      => '邀请好友',
        TaskTypeEnum::TASK_TYPE_SUB_NEW     => '新手任务',
        TaskTypeEnum::TASK_TYPE_SUB_COMMON  => '日常任务',
    ]; // 任务类型名称

    /**
     * @return static
     * tag
     */
    final public static function tag():self
    {
        $thisObject                         = self::tagGet();
        if($thisObject instanceof self){
            $thisObject->DbAuto             = self::getDbAuto();
        }
        return $thisObject;
    }

    /**
     * @param int $taskType
     * @return string
     * getTaskTypeName
     */
    public function getTaskTypeName(int $taskType):string
    {
        return $this->taskTypeNameList[$taskType]??'';
    }

    /**
     * @param int $taskId
     * @return array
     * getTaskInfoSrc
     */
    public function getTaskInfoSrc(int $taskId):array
    {
        if($taskId < 1) return [];
        $sql    = 'SELECT task_id, task_id_parent, task_key, task_type, task_title, task_desc, task_data, task_status, task_create_time, task_update_time FROM '.$this->DbAuto->getTableNameAll('task_record').' WHERE task_id='.$taskId.' AND task_delete=0';
        $isFail = false;
        $info   = $this->DbAuto->getDataOne($sql, $isFail);
        if($isFail || !isset($info['task_id'])) return [];
        return $info;
    }

    /**
     * @param array $taskIdList
     * @return array
     * getTaskInfoSrcBatch
     */
    public function getTaskInfoSrcBatch(array $taskIdList):array
    {
        if(count($taskIdList) < 1) return [];
        $isFail         = false;
        $list           = $this->DbAuto->getData('SELECT task_id, task_id_parent, task_key, task_type, task_title, task_desc, task_data, task_status, task_create_time, task_update_time FROM '.$this->DbAuto->getTableNameAll('task_record').' WHERE task_id IN('.implode(',', $taskIdList).') AND task_delete=0', $isFail);
        $listData       = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $taskIdItem             = intval($item['task_id']??0);
            if($taskIdItem < 1) continue;
            $listData[$taskIdItem]  = $item;
        }
        return $listData;
    }

    /**
     * @param Page $Page
     * @param array $whereData
     * @return TaskListVO|null
     * getTaskList
     */
    public function getTaskList(Page $Page, array $whereData): ?TaskListVO
    {
        $limitString        = $Page->getLimitString();
        $whereString        = ' WHERE task_delete=0 ';
        // 检索条件
        if(count($whereData) > 0)foreach ($whereData as $key => $val){
            switch ($key){
                case TaskListDTO::_taskId:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_id='. intval($val);
                    break;
                case TaskListDTO::_type:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_type='. intval($val);
                    break;
                case TaskListDTO::_taskIdParentId:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_id_parent='. intval($val);
                    break;
                case TaskListDTO::_key:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_key LIKE \'%'.$this->DbAuto->getRealEscapeString($val).'%\'';
                    break;
                case TaskListDTO::_title:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_title LIKE \'%'.$this->DbAuto->getRealEscapeString($val).'%\'';
                    break;
                case TaskListDTO::_status:
                    $whereString    .= (strlen($whereString)>0?' AND ':'').'task_status='. intval($val);
                    break;
            }
        }
        $isFail             = false;
        $sql                = 'SELECT SQL_CALC_FOUND_ROWS task_id, task_id_parent, task_key, task_type, task_title, task_desc, task_data, task_status, task_create_time, task_update_time FROM '.$this->DbAuto->getTableNameAll('task_record').$whereString.' ORDER BY task_id DESC '.$limitString;
        $list               = $this->DbAuto->getData($sql, $isFail);
        $totalNum           = $this->DbAuto->getDataInt('SELECT FOUND_ROWS() as num', 'num');
        if($isFail) return null;
        $TaskVOList         = [];
        if(CommArray::isForeach($list)){
            $taskIdParentList   = array_unique(array_map('intval', array_column($list, 'task_id_parent')));
            $taskInfoSrcList    = $this->getTaskInfoSrcBatch($taskIdParentList);
            foreach($list as $item){
                $taskIdItem             = intval($item['task_id']);
                if($taskIdItem < 1) continue;
                $TaskVO                 = $this->getTaskVO($item);
                if(!($TaskVO instanceof TaskVO)) continue;
                $taskIdParentItem       = intval($item['task_id_parent']);
                if($taskIdParentItem > 0){
                    $taskInfoSrcParent  = $taskInfoSrcList[$taskIdParentItem]??null;
                    $TaskVO->setTaskParentTitle($taskInfoSrcParent['task_title']??'');
                }
                $TaskVOList[]           = $TaskVO;
            }
        }
        $TaskListVO         = new TaskListVO();
        $TaskListVO->setList($TaskVOList);
        $TaskListVO->setPage($Page->getPageVO($totalNum));
        return $TaskListVO;
    }

    /**
     * @param array $info
     * @return TaskVO|null
     * getTaskVO
     */
    public function getTaskVO(array $info):?TaskVO
    {
        $taskId         = intval($info['task_id']??0);
        if($taskId < 1) return null;
        $TaskVO         = new TaskVO();
        $TaskVO->setTaskId($taskId);
        $TaskVO->setTaskIdParent(intval($info['task_id_parent']));
        $TaskVO->setKey(trim($info['task_key']));
        $TaskVO->setType(TaskTypeEnum::parseValue($info['task_type']));
        $TaskVO->setTitle(trim($info['task_title']));
        $TaskVO->setDesc(trim($info['task_desc']));
        $TaskVO->setStatus(YesOrNoEnum::parseValue($info['task_status']));
        $TaskVO->setCreateTime(intval($info['task_create_time']));
        $TaskVO->setUpdateTime(intval($info['task_update_time']));
        $taskDataJson   = $info['task_data']??'[]';
        switch ($TaskVO->getType()){
            case TaskTypeEnum::TASK_TYPE_NOTICE:
                $TaskConfNoticeVO       = new TaskConfNoticeVO();
                if($TaskConfNoticeVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfNotice($TaskConfNoticeVO);
                break;// 订阅消息
            case TaskTypeEnum::TASK_TYPE_BIND:
                $TaskConfBindVO         = new TaskConfBindVO();
                if($TaskConfBindVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfBind($TaskConfBindVO);
                break;// 绑定第三方
            case TaskTypeEnum::TASK_TYPE_WATCH_AD:
                $TaskConfWatchAdVO      = new TaskConfWatchAdVO();
                if($TaskConfWatchAdVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfWatchAd($TaskConfWatchAdVO);
                break;// 看视频得看点
            case TaskTypeEnum::TASK_TYPE_THEATER:
                $TaskConfTheaterVO      = new TaskConfTheaterVO();
                if($TaskConfTheaterVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfTheater($TaskConfTheaterVO);
                break;// 剧场看一看
            case TaskTypeEnum::TASK_TYPE_CHASING:
                $TaskConfChasingVO      = new TaskConfChasingVO();
                if($TaskConfChasingVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfChasing($TaskConfChasingVO);
                break;// 天天追剧
            case TaskTypeEnum::TASK_TYPE_SHARE_APP:
                $TaskConfShareAppVO     = new TaskConfShareAppVO();
                if($TaskConfShareAppVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfShareApp($TaskConfShareAppVO);
                break;// 分享视频App
            case TaskTypeEnum::TASK_TYPE_PLAY:
                $TaskConfPlayVO         = new TaskConfPlayVO();
                if($TaskConfPlayVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfPlay($TaskConfPlayVO);
                break;// 看新剧
            case TaskTypeEnum::TASK_TYPE_RECHARGE:
                $TaskConfRechargeVO     = new TaskConfRechargeVO();
                if($TaskConfRechargeVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfRecharge($TaskConfRechargeVO);
                break;// 充值回馈
            case TaskTypeEnum::TASK_TYPE_CHECK:
                $TaskConfCheckVO        = new TaskConfCheckVO();
                if($TaskConfCheckVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfCheck($TaskConfCheckVO);
                break;// 签到
            case TaskTypeEnum::TASK_TYPE_WATCH:
                $TaskConfWatchVO        = new TaskConfWatchVO();
                if($TaskConfWatchVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfWatch($TaskConfWatchVO);
                break; // 看视频领奖励
            case TaskTypeEnum::TASK_TYPE_LOTTERY:
                $TaskConfLotteryVO  = new TaskConfLotteryVO();
                if($TaskConfLotteryVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfLottery($TaskConfLotteryVO);
                break; // 福利转盘
            case TaskTypeEnum::TASK_TYPE_INVITE:
                $TaskConfInviteVO      = new TaskConfInviteVO();
                if($TaskConfInviteVO->mergeFromJsonStrTry($taskDataJson, true)) $TaskVO->setConfInvite($TaskConfInviteVO);
                break; // 邀请好友
            default:
                break;
        }
        return $TaskVO;
    }

    /**
     * @param int $taskId
     * @param array $setData
     * @param bool $updateLotteryVersion
     * @return bool
     * taskEdit
     */
    public function taskEdit(int $taskId, array $setData, bool $updateLotteryVersion=false):bool
    {
        if($taskId < 1 || count($setData) < 1) return false;
        $setString      = '';
        foreach ($setData as $key => $val){
            switch ($key){
                case TaskEditDTO::_taskIdParent:
                    $setString      .= (strlen($setString) > 0?', ':'').'task_id_parent='.intval($val);
                    break;
                case TaskEditDTO::_title:
                    $setString      .= (strlen($setString) > 0?', ':'').'task_title=\''.$this->DbAuto->getRealEscapeString($val).'\'';
                    break;
                case TaskEditDTO::_desc:
                    $setString      .= (strlen($setString) > 0?', ':'').'task_desc=\''.$this->DbAuto->getRealEscapeString($val).'\'';
                    break;
                case TaskEditDTO::_status:
                    $setString      .= (strlen($setString) > 0?', ':'').'task_status='.intval($val);
                    break;
                case 'taskData':
                    $setString      .= (strlen($setString) > 0?', ':'').'task_data=\''.$this->DbAuto->getRealEscapeString($val).'\'';
                    break;
            }
        }
        if(strlen($setString) < 1) return false;
        $currTime       = CommTime::getTimeStamp();
        $sql            = 'UPDATE '.$this->DbAuto->getTableNameAll('task_record').' SET '.$setString.', task_update_time='.$currTime.' WHERE task_id='.$taskId.' AND task_delete=0';
        $result         = $this->DbAuto->getDataNum($sql)>0;
        $result && $updateLotteryVersion && $this->updateTaskLotteryVersion();
        return $result;
    }

    /**
     * @param int $type
     * @param array $setData
     * @param array $taskData
     * @param bool $updateLotteryVersion
     * @return bool
     * getTaskData
     */
    public function getTaskData(int $type, array $setData, array &$taskData, bool &$updateLotteryVersion=false):bool
    {
        $taskData   = [];
        switch ($type){
            case TaskTypeEnum::TASK_TYPE_NOTICE:
                if(!isset($setData[TaskEditDTO::_confNotice]) || !is_array($setData[TaskEditDTO::_confNotice]) || count($setData[TaskEditDTO::_confNotice]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confNotice];
                $TaskConfNoticeDTO      = new TaskConfNoticeDTO();
                if(!$TaskConfNoticeDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfNoticeDTO->getDataJsonArray([], true);
                break;// 订阅消息
            case TaskTypeEnum::TASK_TYPE_BIND:
                if(!isset($setData[TaskEditDTO::_confBind]) || !is_array($setData[TaskEditDTO::_confBind]) || count($setData[TaskEditDTO::_confBind]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confBind];
                $TaskConfBindDTO        = new TaskConfBindDTO();
                if(!$TaskConfBindDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfBindDTO->getDataJsonArray([], true);
                break;// 绑定第三方
            case TaskTypeEnum::TASK_TYPE_WATCH_AD:
                if(!isset($setData[TaskEditDTO::_confWatchAd]) || !is_array($setData[TaskEditDTO::_confWatchAd]) || count($setData[TaskEditDTO::_confWatchAd]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confWatchAd];
                $TaskConfWatchAdDTO     = new TaskConfWatchAdDTO();
                if(!$TaskConfWatchAdDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfWatchAdDTO->getDataJsonArray([], true);
                break;// 看视频得看点
            case TaskTypeEnum::TASK_TYPE_THEATER:
                if(!isset($setData[TaskEditDTO::_confTheater]) || !is_array($setData[TaskEditDTO::_confTheater]) || count($setData[TaskEditDTO::_confTheater]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confTheater];
                $TaskConfTheaterDTO     = new TaskConfTheaterDTO();
                if(!$TaskConfTheaterDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfTheaterDTO->getDataJsonArray([], true);
                break;// 剧场看一看
            case TaskTypeEnum::TASK_TYPE_CHASING:
                if(!isset($setData[TaskEditDTO::_confChasing]) || !is_array($setData[TaskEditDTO::_confChasing]) || count($setData[TaskEditDTO::_confChasing]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confChasing];
                $TaskConfChasingDTO     = new TaskConfChasingDTO();
                if(!$TaskConfChasingDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfChasingDTO->getDataJsonArray([], true);
                break;// 天天追剧
            case TaskTypeEnum::TASK_TYPE_SHARE_APP:
                if(!isset($setData[TaskEditDTO::_confShareApp]) || !is_array($setData[TaskEditDTO::_confShareApp]) || count($setData[TaskEditDTO::_confShareApp]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confShareApp];
                $TaskConfShareAppDTO    = new TaskConfShareAppDTO();
                if(!$TaskConfShareAppDTO->mergeFromArrayTry($data, true))return false;
                $taskData               = $TaskConfShareAppDTO->getDataJsonArray([], true);
                break;// 分享视频App
            case TaskTypeEnum::TASK_TYPE_PLAY:
                if(!isset($setData[TaskEditDTO::_confPlay]) || !is_array($setData[TaskEditDTO::_confPlay]) || count($setData[TaskEditDTO::_confPlay]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confPlay];
                $TaskConfPlayDTO        = new TaskConfPlayDTO();
                if(!$TaskConfPlayDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfPlayDTO->getDataJsonArray([], true);
                break;// 看新剧
            case TaskTypeEnum::TASK_TYPE_RECHARGE:
                if(!isset($setData[TaskEditDTO::_confRecharge]) || !is_array($setData[TaskEditDTO::_confRecharge]) || count($setData[TaskEditDTO::_confRecharge]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confRecharge];
                $TaskConfRechargeDTO    = new TaskConfRechargeDTO();
                if(!$TaskConfRechargeDTO->mergeFromArrayTry($data, true))return false;
                $taskData               = $TaskConfRechargeDTO->getDataJsonArray([], true);
                break;// 充值回馈
            case TaskTypeEnum::TASK_TYPE_CHECK:
                if(!isset($setData[TaskEditDTO::_confCheck]) || !is_array($setData[TaskEditDTO::_confCheck]) || count($setData[TaskEditDTO::_confCheck]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confCheck];
                $TaskConfCheckDTO       = new TaskConfCheckDTO();
                if(!$TaskConfCheckDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfCheckDTO->getDataJsonArray([], true);
                break;// 签到
            case TaskTypeEnum::TASK_TYPE_WATCH:
                if(!isset($setData[TaskEditDTO::_confWatch]) || !is_array($setData[TaskEditDTO::_confWatch]) || count($setData[TaskEditDTO::_confWatch]) < 1) return false;
                $data                                   = $setData[TaskEditDTO::_confWatch];
                $TaskConfWatchDTO                       = new TaskConfWatchDTO();
                if(!$TaskConfWatchDTO->mergeFromArrayTry($data, true)) return false;
                $taskData                               = $TaskConfWatchDTO->getDataJsonArray([], true);
                $taskData[TaskConfWatchDTO::_maxNum]    = count($taskData[TaskConfWatchDTO::_rewardNumList]);
                break; // 看视频领奖励
            case TaskTypeEnum::TASK_TYPE_LOTTERY:
                if(!isset($setData[TaskEditDTO::_confLottery]) || !is_array($setData[TaskEditDTO::_confLottery]) || count($setData[TaskEditDTO::_confLottery]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confLottery];
                $TaskConfLotteryDTO     = new TaskConfLotteryDTO();
                if(!$TaskConfLotteryDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfLotteryDTO->getDataJsonArray([], true);
                $updateLotteryVersion   = true;
                break; // 福利转盘
            case TaskTypeEnum::TASK_TYPE_INVITE:
                if(!isset($setData[TaskEditDTO::_confInvite]) || !is_array($setData[TaskEditDTO::_confInvite]) || count($setData[TaskEditDTO::_confInvite]) < 1) return false;
                $data                   = $setData[TaskEditDTO::_confInvite];
                $TaskConfInviteDTO      = new TaskConfInviteDTO();
                if(!$TaskConfInviteDTO->mergeFromArrayTry($data, true)) return false;
                $taskData               = $TaskConfInviteDTO->getDataJsonArray([], true);
                break; // 邀请好友
            default:
                break;
        }
        return true;
    }

    /**
     * @return string
     * getTaskKey
     */
    private function getTaskKey():string
    {
        $minLength          = 8;        // 最小长度
        $maxLength          = 16;       // 最大长度
        $maxNum             = 200;
        $currNum            = 1;
        $indexNum           = 1;
        $taskKey            = CommString::genRandStr($minLength);
        while($currNum <= $maxNum){
            $taskIdFind     = $this->DbAuto->getDataInt('SELECT tlyi_id FROM '.$this->DbAuto->getTableNameAll('task_record').' WHERE binary task_key=\''.$this->DbAuto->getRealEscapeString($taskKey).'\'', 'task_id');
            if($taskIdFind < 1) break;
            if($indexNum >= 50){                // 失败自增长度1
                $indexNum   = 0;
                $minLength  += 1;
            }
            if($minLength > $maxLength) break;  // 长度封顶
            $taskKey        = CommString::genRandStr($minLength);
            ++$indexNum;
            ++$currNum;
        }
        return $taskKey;
    }

    /**
     * @return bool
     * updateTaskLotteryVersion
     */
    public function updateTaskLotteryVersion():bool
    {
        $typeType   = TaskTypeEnum::TASK_TYPE_LOTTERY;
        $sql        = 'UPDATE '.$this->DbAuto->getTableNameAll('task_record').' SET task_data=JSON_SET(task_data, "$.versionNum", JSON_EXTRACT(task_data, "$.versionNum")+1) WHERE task_type='.$typeType;
        return $this->DbAuto->getDataNum($sql)>0;
    }
}